# -*- coding: utf-8 -*- 
# @Time : 2020-11-26 23:56 
# @Author : derek.zhang 
# @File : fake_user.py 
# @Software: PyCharm

from django.contrib.auth.models import User, Group

def fake_user_data():
    User.objects.all().delete()
    Group.objects.all().delete()
    print('delete all user data')
    User.objects.create_user(username='Dylan', password='password')
    User.objects.create_user(username='Derek', password='password')
    User.objects.create_user(username='James', password='password')
    User.objects.create_user(username='Jack', password='password')
    User.objects.create_user(username='Eric', password='password')
    User.objects.create_user(username='Boat', password='password')
    admin = User.objects.create_superuser('admin','admin@demo.com','admin123')
    root =User.objects.create_superuser('root', 'root@demo.com', 'root')
    admin_group = Group.objects.create(name='admin')
    Group.objects.create(name='test')

    Group.objects.create(name='dev')
    Group.objects.create(name='operate')
    # 将admin 和 root 加入admin 用户组
    admin_users = [admin, root]
    admin_group.user_set.set(admin_users)
    print('create all user data')